home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9815 < prev    next >
Encoding:
Text File  |  1996-08-05  |  962 b   |  25 lines

  1. Newsgroups: comp.lang.c++
  2. Path: presby.edu!jtbell
  3. From: jtbell@presby.edu (Jon Bell)
  4. Subject: Re: Inheritance vs Templates
  5. Message-ID: <Dnr699.1xM@presby.edu>
  6. Date: Mon, 4 Mar 1996 17:07:56 GMT
  7. References: <4hf345$bnp@gwen.pcug.co.uk>
  8. Organization: Presbyterian College, Clinton, South Carolina USA
  9.  
  10.  Andy  <williams@template.com> wrote:
  11. >It seems that templates do nothing extra (except efficiency ?)
  12. >that could not be achieved using inheritance, and it seems that 
  13. >inheritance is a more elegant approach?
  14.  
  15. Have you tried to write a generic Stack class in such a way that you can 
  16. have a Stack of integers, a Stack of doubles, and a Stack of, say, 
  17. Employees, all in the same program?
  18.  
  19. I think you'll find that this is difficult or impossible using 
  20. inheritance alone, but is almost trivial using templates.
  21.  
  22. -- 
  23. Jon Bell <jtbell@presby.edu>                        Presbyterian College
  24. Dept. of Physics and Computer Science        Clinton, South Carolina USA
  25.